<%@page import="util.enviaEmail"%>
<%
Connection conn = null;
try {
	conn = new Conexao().getConexao();
} catch (Exception e) {
	new enviaEmail().enviar(e);
	out.print("falhaConexao");
	return;
}
%>
<%@page import="conexao.Conexao"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="dao.OSDao"%>
<%@page import="bean.OSBean"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/blue/style.css" />
<script src="js/jquery.tablesorter.min.js"></script>
<script>
	$(function() {

		$("#tbodyRetornadas tr td img").click(function() {
			if ($(this).attr("title") != "finalizar") {
				var id = $(this).parent().parent().attr("id");
				var nome = $(this).parent().attr("id");
				
				$("#descricao").val("\n" + $("#descricao"+id).html() + "\n\n" + $("#comentario"+id).html());
				$("#descricao").scrollTop(999999);
				$("#descricao").show();
				$("#fontMsn").html("");
				$("#idOs").val(id);
				$("#nomeCliente").html("OS nº: "+id +"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cliente: "+ nome);
			} else {
				$("#dialogConfirmaId").val($(this).parent().parent().attr("id"));
				$("#dialogConfirm").dialog("open");
			}

		});

	});
</script>
</head>
<body>
	<table class="tablesorter">
		<tbody id="tbodyRetornadas">
			<%
				List<OSBean> voltouOs = new OSDao().getListaOS(conn,
						"('voltouDesigner')", (Integer) request.getSession()
								.getAttribute("id"));
				if (!voltouOs.isEmpty()) {
					for (int n = 0; n < voltouOs.size(); n++) {
						SimpleDateFormat df = new SimpleDateFormat(
								"dd/MM/yyyy HH:mm");
						String data = df.format(voltouOs.get(n).getDataDesigner());
			%>
			<tr id="<%=voltouOs.get(n).getId()%>"
				<%if (voltouOs.get(n).getUrgente() == 1) {%> style="color: red;"
				<%}%>>
				<td width="27"><%=voltouOs.get(n).getId()%></td>
				<td><%=voltouOs.get(n).getNomeCliente()%></td>
				<td width="85" align="center"><%=data%></td>
				<td align="center" width="57" id="<%=voltouOs.get(n).getNomeCliente()%>"><img src="imagens/magnifier-zoom.png" style="cursor: pointer;" title="Visualizar Descrição e Comentário"> 
				<img src="imagens/tick-button.png" style="cursor: pointer;" title="finalizar">
				<div id="descricao<%=voltouOs.get(n).getId()%>" style="display: none;"><%=voltouOs.get(n).getDescricao()%></div>
				<div id="comentario<%=voltouOs.get(n).getId()%>" style="display: none;"><%if(voltouOs.get(n).getComentario() != null){%><%=voltouOs.get(n).getComentario()%><%}%></div>	
				</td>
			</tr>
			<%
				}
				} else {
			%>
			<tr>
				<td colspan="3">Nenhuma OS Retornada</td>
			</tr>
			<%
				}
				conn.close();
			%>
		</tbody>
	</table>
</body>
</html>